#!/bin/bash
#Usage: $0 [func_name [ext_flag]] [src_file]
#e.g.
#	$ ./cflow.sh main --omit-arguments ./task/obu_control/*.c 2>/dev/null

FUNC="main"
SRC="*.c"

if [ -n  "$1" ]; then
	FUNC=$1
fi

if [ -n  "$2" ]; then
	FUNC=""
	SRC=$@
fi

# exclude functions list
. ./exclude.sh
. ./config

# add your default exclude functions list
if [ -n "${IEXCLUDE_FUNC}" ]; then
	EXCLUDE_FUNC="${IEXCLUDE_FUNC}\|${GEXCLUDE_FUNC}"
else
	EXCLUDE_FUNC="${GEXCLUDE_FUNC}"
fi

./cflow2dot --main ${FUNC} ${SRC} | grep -v -w "${EXCLUDE_FUNC}"
